package com.wind.trademark.notice.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Repository;

import com.wind.trademark.common.dao.BaseDao;
import com.wind.trademark.common.vo.PageBean;
import com.wind.trademark.common.vo.PageParam;
import com.wind.trademark.notice.dao.NoticeDao;
import com.wind.trademark.notice.vo.NoticeVo;
@Repository
public class NoticeDaoImpl implements NoticeDao {

	@Autowired
	private BaseDao baseDao;
	@Override
	public PageBean queryNotice(PageParam pageParam, Map<String, Object> params) {
		String sql= NoticeSql.queryNoticeSQL(params);
		PageBean pageBean=baseDao.queryPageBeanAndMapping(sql, pageParam,NoticeVo.class, params);
		return pageBean;
	}
	@Override
	public void deleteNotices(List<Long> ids) {
		String sql= NoticeSql.deleteNotices();
		baseDao.getNamedParameterJdbcTemplate().update(sql,new MapSqlParameterSource().addValue("ids",ids));
	}
	@Override
	public void deleteNoReceiveMailByNoticeId(Long noticeId) {
		String sql= NoticeSql.deleteNoReceiveMailByNoticeId();
		baseDao.getNamedParameterJdbcTemplate().update(sql,new MapSqlParameterSource().addValue("noticeId",noticeId));

	}
	@Override
	public void deleteNoReceiveMessageByNoticeId(Long noticeId) {
		String sql= NoticeSql.deleteNoReceiveMessageByNoticeId();
		baseDao.getNamedParameterJdbcTemplate().update(sql,new MapSqlParameterSource().addValue("noticeId",noticeId));

	}
	@Override
	public void deleteNoReceiveSystemByNoticeId(Long noticeId) {
		String sql= NoticeSql.deleteNoReceiveSystemByNoticeId();
		baseDao.getNamedParameterJdbcTemplate().update(sql,new MapSqlParameterSource().addValue("noticeId",noticeId));

	}
	@Override
	public List<Map<String, Object>> loadNoticeMobileList() {
		String loadUserMobileListSql= NoticeSql.loadUserMobileList();
		List<Map<String, Object>> mobileList=baseDao.getJdbcTemplate().queryForList(loadUserMobileListSql);
		return mobileList;
	}
	@Override
	public List<Map<String, Object>> loadNoticeEmailList() {
		String loadUserMobileListSql= NoticeSql.loadUserEmailList();
		List<Map<String, Object>> mobileList=baseDao.getJdbcTemplate().queryForList(loadUserMobileListSql);
		return mobileList;
	}
}
